/*
 * @Author: Snow
 * @Date: 2021-09-25 10:53:38
 * @Description: 
 */
export class Util {
    /**
     * @Author: Snow
     * @description: 角度转弧度
     * @param {number} d
     * @return {*}
     */
    public static degToRad(d: number): number {
        return d * Math.PI / 180;
    }

    /**
     * @Author: Snow
     * @description: 弧度转角度
     * @param {number} r
     * @return {*}
     */
    public static radToDeg(r: number): number {
        return r * 180 / Math.PI;
    }

    /**
     * @Author: Snow
     * @description: 范围取随机数
     * @param {number} min
     * @param {number} max
     * @return {*}
     */
    public static rand(min: number, max?: number): number {
        if (max === undefined) {
            max = min;
            min = 0;
        }
        return min + Math.random() * (max - min);
    };

    /**
     * @Author: Snow
     * @description: 随机整数
     * @param {number} range
     * @return {*}
     */
    public static randInt(range: number): number {
        return Math.floor(Math.random() * range);
    };

    /**
     * @Author: Snow
     * @description:是否是2的整数次方 
     * @param {number} value
     * @return {*}
     */
    public static isPowerOf2(value: number): boolean {
        return (value & (value - 1)) == 0;
    }


}